import axios from "axios";
import serviceConfig from "@/service/config";
import qs from "qs";

/**
 * 注册方法
 * @param {用户信息}} user,JSON对象,建议包含属性如下:
 *              uname:注册用户名-邮箱验证
 *              pswd:账户密码-[6-12位]
 *              checkpswd:校验账户密码-[6-12位]
 *              verifycode:邮箱验证码-可通过电子邮件发送接口获取
 */
export function register(user) {
    return axios({
        method: 'POST',
        url: serviceConfig.baseUrl + '/user/POST/register',
        data: qs.stringify(user),
    })
}


/**
 * 登录方法
 * @param {用户对象}} user JSON对象,建议包含属性如下:
 *              uname:账户名-邮箱验证
 *              pswd:账户密码-[6-12位]
 */
export function login(user) {
    return axios({
        method: 'POST',
        url: serviceConfig.baseUrl + '/user/POST/login',
        data: qs.stringify(user),
        responseType: 'json',
        responseEncoding: 'UTF-8',
    })
}